﻿package  {
	
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flashx.textLayout.accessibility.TextAccImpl;
	
	// this class is organised as a singleton which is a commonly used 'software design pattern'
	// (more about this later) - it makes it easy to access the class from anywhere in your program
	// without having to have an variable. It is a good choice for making reusable components that
	// can be dropped into a new project
	public class TextPanel extends MovieClip {
		
		//a textField, but you could add other ones too
		public var textField:TextField ;
		//static variable which is used to store an instance of the class
		//this is an essential feature of the singleton pattern
		public static var instance:TextPanel=null;
		
		public function TextPanel() {
			// constructor code
			textField = new TextField();
			addChild(textField);
			textField.x=0;
			textField.y=0;
			textField.text = "text goes here";
		}
		
		
		//getInstance function is the singleton access function
		// it is static so can be accessed from anywhere without having an object created first
		//getInstance returns a TextPanel instance which can then be manipulated as normal
		public static function getInstance():TextPanel
		{
			if (instance==null)
			{
				trace("creating instance of textPanel");
				instance=new TextPanel();
			}
			return instance;
		}

	}
	
}
